#include <gnome.h>
#include "list_model.h"

GtkTreeModel *
create_model_Graph (void)
{
  GtkListStore  *listStore;
  GtkTreeIter    iter;

  listStore = gtk_list_store_new (PATH_COLS, 
		  G_TYPE_STRING, 
		  G_TYPE_STRING, 
		  G_TYPE_STRING, 
		  G_TYPE_STRING );

  return GTK_TREE_MODEL(listStore);
}

GtkWidget *
create_view_and_model_Graph (void)
{
	GtkTreeViewColumn   *col;
	GtkCellRenderer     *renderer;
	GtkWidget           *view;
	GtkTreeModel        *model;

	view = gtk_tree_view_new();

	/* --- Column #1 --- */
	col = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(col, "Source URL");
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(col, renderer, TRUE);
	gtk_tree_view_column_add_attribute(col, renderer, "text", PATH_COL_URLS);
	gtk_tree_view_column_set_min_width (col, 0);
	g_object_set (G_OBJECT(col), "resizable", TRUE, NULL);

	/* --- Column #2 --- */
	col = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(col, "MIME");
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(col, renderer, TRUE);
	gtk_tree_view_column_add_attribute(col, renderer, "text", PATH_COL_MIME);
	gtk_tree_view_column_set_min_width (col, 0);
	g_object_set (G_OBJECT(col), "resizable", TRUE, NULL);

	/* --- Column #3 --- */
	col = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(col, "HTTP Code");
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(col, renderer, TRUE);
	gtk_tree_view_column_add_attribute(col, renderer, "text", PATH_COL_CODE);
	gtk_tree_view_column_set_min_width (col, 0);
	g_object_set (G_OBJECT(col), "resizable", TRUE, NULL);

	/* --- Column #4 --- */
	col = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(col, "Target URL");
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(col, renderer, TRUE);
	gtk_tree_view_column_add_attribute(col, renderer, "text", PATH_COL_URLT);
	gtk_tree_view_column_set_min_width (col, 0);
	g_object_set (G_OBJECT(col), "resizable", TRUE, NULL);

	model = create_model_Graph();
	gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
	g_object_unref(model); /* destroy model automatically with view */
	gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)),
		GTK_SELECTION_NONE);

  return view;
}
